# _*_ coding：UTF-8 _*_
# @Time：2021/9/411:19
# @Author：JYZ
# @Project：oneWork

# GET 请求 多个参数编码格式化

import urllib.request
import urllib.parse


url = "https://www.baidu.com/s?"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"}

# 将中文转码 unicode 编码（import urllib.parse） %E7%8E%8B%E6%96%87%E9%B9%8F
data = {"wd": "王文鹏", "sex": "男"}

name = urllib.parse.urlencode(data)

# 请求对象的定制
request = urllib.request.Request(url=url + name, headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode("utf-8");
print(content)
